<template>
 <div class="page-container">
     <div class="toolbar">
         <el-row>
             <el-tabs type="border-card">
                 <el-tab-pane label="基本信息">
                     <el-form :inline="true" :model="dataForm" label-width="150px" style="text-align:left;" ref="dataForm" :rules="dataFormRules" class="form">
                         <el-row style="margin-top: -20px;" class="searchDialog-input">
                             <el-divider content-position="center">
                                 <span style="font-size:16px;font-weight:800">基本信息</span>
                             </el-divider>

                             <el-form-item label="id：" v-show="false">
                                 <el-input v-model="dataForm.id" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="SAP采购订单号： ">
                                 <el-input v-model="dataForm.purchaseOrderSap" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="SAP采购申请编号： ">
                                 <el-input v-model="dataForm.purchaseApplyNumber" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="采购订单类型：">
                                 <el-select v-model="dataForm.purchaseOrderType" placeholder="请选择采购订单类型">
                                     <el-option label="ZRE5 ZRE5一次性供应商返厂" value="1"></el-option>
                                     <el-option label="ZRE6 ZRE6项目订单备货返厂" value="2"></el-option>
                                     <el-option label="NB NB标准采购订单" value="3"></el-option>
                                     <el-option label="UB3 UB3门店退回仓库" value="4"></el-option>
                                     <el-option label="UB1 UB1仓库到门店（手动）" value="5"></el-option>
                                 </el-select>
                             </el-form-item>
                             <el-form-item label="采购组：">
                                 <el-input v-model="dataForm.purchaseGorup" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="公司代码：">
                                 <el-input v-model="dataForm.companyCode" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="供应商编号：">
                                 <el-input v-model="dataForm.supplierName" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="供应商名称：">
                                 <el-input v-model="dataForm.supplierCode" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="文本：">
                                 <el-input v-model="dataForm.textExplain" placeholder="请输入"></el-input>
                             </el-form-item>
                             <!-- <el-form-item label="状态：1待传输；2已传输SAP；3已预约；4已收货；5已发货；6同步SAP失败；7发货失败；8收货失败；9审批中；10已审批；11审批退回">
        <el-input v-model="dataForm.status" placeholder="请输入"></el-input>
       </el-form-item> -->
                             <el-form-item label="运营方ID：" label-width="166px">
                                 <el-input v-model="dataForm.deptId" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="商家ID：">
                                 <el-input v-model="dataForm.merchantId" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="商家名称：">
                                 <el-input v-model="dataForm.merchantName" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="店铺Id：">
                                 <el-input v-model="dataForm.storeId" placeholder="请输入"></el-input>
                             </el-form-item>
                             <el-form-item label="店铺名称：">
                                 <el-input v-model="dataForm.storeName" placeholder="请输入"></el-input>
                             </el-form-item>

                             <!-- <el-form-item label="删除标志，0：未删除；1：已删除">
        <el-input v-model="dataForm.deleteFlag" placeholder="请输入"></el-input>
       </el-form-item> -->
                         </el-row>
                     </el-form>
                     <div class="tool-wrap">
                         <div class="left-area">
                             <el-button-group>
                                 <el-button type="primary" size="small" @click="submitForm()">保存</el-button>
                                 <el-button type="primary" size="small" @click="$router.go(-1)">取消</el-button>
                             </el-button-group>
                         </div>
                     </div>
                 </el-tab-pane>
             </el-tabs>
         </el-row>
     </div>
 </div>
</template>

<script>
//一.导包区
import jicTable from '@/components/jicComponentGallery/jicTable';
import {
    mapState
} from "vuex";
import ThemePicker from "@/components/ThemePicker";
import LangSelector from "@/components/LangSelector";
import VDistpicker from 'v-distpicker';
import elTree from '@/views/tree/src/tree.vue'

//二.数据输出区
export default {

    //2.1 注册组件
    components: {
        jicTable,
        ThemePicker,
        LangSelector,
        VDistpicker,
        elTree,
    },

    //2.2 数据初始化区
    data() {
        return {

            //2.2.1 公共数据初始化
            searchSize: 'mini',

            // 2.2.2 form 表单数据初始化 
            dataForm: {
                id: null,
                purchaseOrderSap: null,
                purchaseApplyNumber: null,
                purchaseOrderType: null,
                purchaseGorup: null,
                companyCode: null,
                supplierName: null,
                supplierCode: null,
                textExplain: null,
                status: null,
                deptId: null,
                merchantId: null,
                merchantName: null,
                storeId: null,
                storeName: null,
                createTime: null,
                creater: null,
                updateTime: null,
                updater: null,
                deleteFlag: null,
            },
            //trigger 为blur 表示丢失焦点;为change 表示值发生变化;
            dataFormRules: {
                id: [{
                        required: true,
                        message: "请输入id",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                purchaseOrderSap: [{
                        required: true,
                        message: "请输入SAP采购订单号 ",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                purchaseApplyNumber: [{
                        required: true,
                        message: "请输入SAP采购申请编号 ",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                purchaseOrderType: [{
                        required: true,
                        message: "请输入采购订单类型 ：1=ZRE5 ZRE5一次性供应商返厂；2=ZRE6 ZRE6项目订单备货返厂；3=NB NB标准采购订单；4=UB3 UB3门店退回仓库；5=UB1 UB1仓库到门店（手动）",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                purchaseGorup: [{
                        required: true,
                        message: "请输入采购组",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                companyCode: [{
                        required: true,
                        message: "请输入公司代码",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                supplierName: [{
                        required: true,
                        message: "请输入供应商编号",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                supplierCode: [{
                        required: true,
                        message: "请输入供应商名称",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                textExplain: [{
                        required: true,
                        message: "请输入文本",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                status: [{
                        required: true,
                        message: "请输入状态：1待传输；2已传输SAP；3已预约；4已收货；5已发货；6同步SAP失败；7发货失败；8收货失败；9审批中；10已审批；11审批退回",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                deptId: [{
                        required: true,
                        message: "请输入运营方ID",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                merchantId: [{
                        required: true,
                        message: "请输入商家ID",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                merchantName: [{
                        required: true,
                        message: "请输入商家名称",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                storeId: [{
                        required: true,
                        message: "请输入店铺Id",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                storeName: [{
                        required: true,
                        message: "请输入店铺名称",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                createTime: [{
                        required: true,
                        message: "请输入创建日期",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                creater: [{
                        required: true,
                        message: "请输入创建人",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                updateTime: [{
                        required: true,
                        message: "请输入更新日期",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                updater: [{
                        required: true,
                        message: "请输入更新人",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
                deleteFlag: [{
                        required: true,
                        message: "请输入删除标志，0：未删除；1：已删除",
                        trigger: "blur"
                    },
                    {
                        min: 3,
                        max: 5,
                        message: "长度在 0 到 20 个字符",
                        trigger: "blur"
                    },
                ],
            },
            //dialogVisible: false, //// 是否显示弹窗内容;
            //editDialogVisible1: false,//// 是否可编辑弹窗内容;
            //editLoading: false,////是否显示加载时动画效果;

        } //return 完结;
    }, //data()方法 完结;

    //2.3 Vue 方法区
    methods: {
        //2.3.1 公共方法区

        //2.请求列表数据
        getDetail() {
            let this_ = this;
            if (this.$route.params != null && this.$route.params.id != null && this.$route.params.id != '' && this.$route.params.id != "undefined") {
                let params = {};
                params.id = this.$route.params.id;
                this.utils.request.getPurchaseOrderPoDetail(params, function (res) {
                    if (res.code === "0000") {
                        this_.dataForm = res.data;
                    } else {
                        this_.$message({
                            message: "操作失败, " + data.msg,
                            type: "error"
                        });
                    }
                });
            }
        },

        submitForm: function () {
            this.$refs.dataForm.validate(valid => {
                if (valid) {
                    this.$confirm("确认提交吗？", "提示", {}).then(() => {
                        this.editLoading = true;
                        let params = Object.assign({}, this.dataForm);
                        this.utils.request.savePurchaseOrderPo(params, this.editInfoBack);
                        this.$router.go(-1);
                    });
                }
            });
        },
        // 7.页面弹窗处理方法
        add() {
            this.dialogVisible = true;
        },

        // 8.关闭弹窗
        handleClose() {
            this.dialogVisible = false;
        },

        /*图片预览*/
        handlePictureCardPreview(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        /*图片移除*/
        handleRemove(file, fileList) {
            console.log(file, fileList);
        },
        //==========2.3.1 JavaScript 自定义方法区==========

    },
    //1.初始化页面调用方法(dom元素绑定后再执行初始化数据操作)
    mounted() {
        this.getDetail();
    },

}
</script>

<style lang="scss" scoped>
/* ele组件样式重置 */
.common-content {
    padding: 10px;
    box-sizing: border-box;

    .search-wrap /deep/ {
        .el-form-item__label {
            height: 32px;
            line-height: 32px;
        }

        .el-form-item__content {
            height: 32px;
            line-height: 32px;
            width: 150px;
        }

        .el-input--mini .el-input__inner {
            height: 32px;
            line-height: 32px;
        }

        .el-date-editor.el-input,
        .el-date-editor.el-input__inner {
            width: 150px;
        }
    }

    /* 多日期样式重置 */
    .el-dater /deep/ .el-form-item__content {
        width: 330px;
    }

    /* 通用工具部分样式 */
    .tool-wrap {
        width: 100%;
        height: auto;
        position: relative;
        overflow: hidden;

        .left-area {
            float: left;
            width: 50%;
            text-align: left;

            button {
                margin-right: 15px;
                border-radius: 5px;
            }
        }

        .right-area {
            float: right;
            width: 50%;
            text-align: right;
        }
    }

    /* 表格部分样式 */
    .table-wrap {
        width: 100%;
        max-height: 600px;
        margin-top: 20px;
    }

    /* 弹窗样式 */
    .dialog-wrap /deep/ .el-dialog__footer {
        text-align: center !important;
    }
}
</style>
